using System;
using System.Collections.Generic;
using System.Text;
using CoastToCoast.Game.Units;

namespace CoastToCoast.Game {
    public class GameMatch {
        private List<Player> _players = new List<Player>();
        public List<Player> Players {
            get { return _players; }
        }

        private Board _board;
        public Board Board {
            get { return _board; }
            set { _board = value; }
        }

        private Board CreateBoard() {
            Board map = new Board(5, 5);
            Cell cell = map.Cells[0][0];
            Unit inf = UnitFactory.CreateUnit<Infantry>(Players[0]);
            inf.Cell = cell;
            cell.Terrain = new LandTile();
            cell.Unit = inf;

            cell = map.Cells[1][0];
            inf = UnitFactory.CreateUnit<Fighter>(Players[0]);
            inf.Cell = cell;
            cell.Terrain = new LandTile();
            cell.Unit = inf;

            cell = map.Cells[2][0];
            inf = UnitFactory.CreateUnit<Fighter>(Players[0]);
            inf.Cell = cell;
            cell.Terrain = new LandTile();
            cell.Unit = inf;

            cell = map.Cells[3][0];
            inf = UnitFactory.CreateUnit<Fighter>(Players[0]);
            cell.Terrain = new LandTile();
            inf.Cell = cell;
            cell.Unit = inf;

            cell = map.Cells[4][0];
            inf = UnitFactory.CreateUnit<Fighter>(Players[0]);
            cell.Terrain = new LandTile();
            inf.Cell = cell;
            cell.Unit = inf;

            cell = map.Cells[0][1];
            cell.Terrain = new LandTile();

            cell = map.Cells[1][1];
            cell.Terrain = new SeaTile();
            inf = UnitFactory.CreateUnit<Bomber>(Players[0]);
            inf.Cell = cell;
            cell.Unit = inf;

            cell = map.Cells[2][1];
            cell.Terrain = new SeaTile();

            cell = map.Cells[3][1];
            cell.Terrain = new SeaTile();
            inf = UnitFactory.CreateUnit<Tank>(Players[0]);
            inf.Cell = cell;
            cell.Unit = inf;

            cell = map.Cells[4][1];
            cell.Terrain = new SeaTile();
            inf = UnitFactory.CreateUnit<Transport>(Players[0]);
            inf.Cell = cell;
            cell.Unit = inf;

            cell = map.Cells[4][3];
            cell.Terrain = new City();

            return map;
        }

        public void Start() {
            Player hao = new Player();
            hao.Name = "Hao";
            Players.Add(hao);
            Board = CreateBoard();

            Players[0].Units[0].Move(Board.Cells[4][4]);
        }

    }
}
